package xdu.lz.netty.e_zerocopy;

import java.io.DataInputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author lizhen
 * @date 2019/8/15 11:03
 * @desc 　传统文件传输
 */
public class NoneZeroCopyServer {
    public static void main(String[] args) throws Exception{
        ServerSocket serverSocket = new ServerSocket(8899);
        while(true){
            //阻塞监听
            Socket socket = serverSocket.accept();
            //二进制流
            DataInputStream dataInputStream = new DataInputStream(socket.getInputStream());
//            FileOutputStream outputStream = new FileOutputStream(new File("E:\\ideaIU-2018.1.1.exe"));
            try {
                byte[] byteArray = new byte[4096];
                int readCount = 0;
                 while (readCount!= -1) {
                     readCount = dataInputStream.read(byteArray, 0, byteArray.length);
//                     outputStream.write(byteArray,0,byteArray.length);
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }
}
